package com.avic.rong.adapter.show;

import android.content.Context;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.avic.rong.R;
import com.avic.rong.bean.show_bean.AchieveBean;

import org.w3c.dom.Text;

import java.util.List;

/**
 * Created by TSJ-2018-0492 on 2019/9/19.
 */

public class AchdemanAdapter extends RecyclerView.Adapter<AchdemanAdapter.AchdemanViewHolder>{

    private Context context;
    private List<AchieveBean.DemandListBean> recomSListBeans;

    public void setRecomSListBeans(List<AchieveBean.DemandListBean> recomSListBeans) {
        this.recomSListBeans = recomSListBeans;
        notifyDataSetChanged();
    }

    public AchdemanAdapter(Context context) {
        this.context = context;
    }



    @NonNull
    @Override
    public AchdemanAdapter.AchdemanViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
        View view = LayoutInflater.from(context).inflate(R.layout.achieve_recomxq_item, viewGroup, false);
        return new AchdemanViewHolder(view);
    }

    @Override
    public void onBindViewHolder(@NonNull AchdemanAdapter.AchdemanViewHolder achdemanViewHolder, int i) {
            if (recomSListBeans!=null){
                AchieveBean.DemandListBean demandListBean = recomSListBeans.get(i);
                achdemanViewHolder.achieve_tjxq_time.setText("剩余时间:"+demandListBean.getLastTime()+"");
                achdemanViewHolder.achieve_tjxq_title.setText(demandListBean.getDemandTitle()+"");
                achdemanViewHolder.achieve_tjxq_user.setText(demandListBean.getTypeName()+"");
            }

    }

    @Override
    public int getItemCount() {
        if (recomSListBeans!=null){
            return recomSListBeans.size();
        }
        return 0;
    }

    public class AchdemanViewHolder extends RecyclerView.ViewHolder {

        private final TextView achieve_tjxq_lei;
        private final TextView achieve_tjxq_time;
        private final TextView achieve_tjxq_title;
        private final TextView achieve_tjxq_user;

        public AchdemanViewHolder(@NonNull View itemView) {
            super(itemView);
            achieve_tjxq_lei = itemView.findViewById(R.id.achieve_tjxq_lei);
            achieve_tjxq_time = itemView.findViewById(R.id.achieve_tjxq_time);
            achieve_tjxq_title = itemView.findViewById(R.id.achieve_tjxq_title);
            achieve_tjxq_user = itemView.findViewById(R.id.achieve_tjxq_user);
        }
    }
}
